package com.jwinni.IO.BufferedReaderAndWriter;

import java.io.*;
import java.util.HashMap;

/*
使用字符缓冲流对文本进行排序(理想化)
 */
public class DemoTxtSourt {

    public static void main(String[] args) {

        try {
            BufferedReader br= new BufferedReader(new FileReader("E:\\wohuo.txt"));
            BufferedWriter bw =  new BufferedWriter(new FileWriter("static/zhaoly.txt"));
            HashMap<String, String> map = new HashMap<>();
            String line;
            while ((line=br.readLine())!=null){
            String[] arr = line.split("~");
                map.put(arr[0],arr[1]);
            }
            for (String key:map.keySet()
                 ) {
                String value = map.get(key);
                bw.write(key+"~" +value);
                bw.flush();
                bw.newLine();
            }

            br.close();
            bw.close();

        }
       catch (IOException e){


       }


    }
}
